home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java Programmer's Toolkit
/
Java Programmer's Toolkit.iso
/
gs3.53
/
gs_cidfn.ps
< prev
next >
Wrap
Text File
|
1996-01-10
|
9KB
|
275 lines
% Copyright (C) 1995 Aladdin Enterprises. All rights reserved.
%
% This file is part of Aladdin Ghostscript.
%
% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
% or distributor accepts any responsibility for the consequences of using it,
% or for whether it serves any particular purpose or works at all, unless he
% or she says so in writing. Refer to the Aladdin Ghostscript Free Public
% License (the "License") for full details.
%
% Every copy of Aladdin Ghostscript must include a copy of the License,
% normally in a plain ASCII text file named PUBLIC. The License grants you
% the right to copy, modify and redistribute Aladdin Ghostscript, but only
% under certain conditions described in the License. Among other things, the
% License requires that the copyright notice and this notice be preserved on
% all copies.
% ProcSet for implementing CID-keyed fonts.
% When this is run, systemdict is still writable.
%**************** This file isn't even close to being usable:
% - It doesn't include the actual character mapper (BuildGlyph).
% - CMap support mostly isn't implemented.
% - It has never been tested on a real font.
%**************** So don't even think of actually trying to use it!
/.setlanguagelevel where { pop 2 .setlanguagelevel } if
.currentglobal true .setglobal
/GS_CIDInit_ProcSet 30 dict dup begin
% ---------------- CIDFont operators ---------------- %
/StartData % <cidfontdict> <(Binary)|(Hex)> <datalength>
% StartData -
{ 2 index begin % CID font dict
20 dict begin % temporary dict
/datalength exch def
(Hex) eq /hex exch def
/cidfont exch def
/startdata currentfile fileposition def
% Read the character data into an array of strings.
% There's no particular reason to prefer long strings over short,
% so we just create a separate string for each character.
/charstrings CIDCount array def
/fontindices FDArray length FDBytes 1 eq { string } { array } ifelse def
0 1 CIDCount 1 sub
{ /cid exch def
currentfile FDBytes GDBytes add cid mul startdata add setfileposition
fontindices cid FDBytes .readint put
/pos GDBytes .readint def
FDBytes .readint pop % skip FD of next entry
GDBytes .readint pos sub
dup 0 eq
{ pop null }
{ currentfile pos setfileposition string readstring pop }
ifelse
charstrings cid 3 -1 roll put
}
for
% Process each font in the FDArray.
% For Type 3 fonts, just do a definefont with an empty Encoding.
% For Type 1 fonts, read the Subrs (don't bother to check for
% duplicates), and set CharStrings to the character data array.
% We don't support embedded Type 0 fonts, but it isn't clear
% whether they're allowed anyway.
cidfont /Encoding [ FDArray
{ dup /FontType get 1 eq
{ dup /CharStrings charstrings put
/Private get
dup /SubrCount known
{ begin /Subrs [ % Private
0 1 SubrCount 1 sub
{ SDBytes mul SubrMapOffset add startdata add
currentfile exch setfileposition
/pos SDBytes .readint def
SDBytes .readint pos sub
currentfile pos setfileposition string readstring pop
}
] readonly def end % Private
}
if pop
}
if
dup /Encoding [] put
dup /FontName get exch definefont
}
forall ] readonly def
% Install the rest of the data in the font.
cidfont /FontType 0 put % ???
cidfont /CharStrings charstrings readonly put
cidfont /FontIndices fontindices readonly put
FontName cidfont /CIDFont defineresource pop
% Wrap up.
end % temporary dict
end % CID font dict
end % resource dict
} bind def
/.readint % <nbytes> .readint <int>
{ 0 exch { 8 bitshift currentfile read pop add } repeat
} bind def
% ---------------- CMap operators ---------------- %
% We create the following structures for character code mapping.
% Map - a multi-level array indexed by the successive bytes of
% the character code. All of the arrays are read-only.
% ------ Font-level operators ------ %
/begincmap % - begincmap -
{ /Map 256 array def
} bind def
/endcmap % - endcmap -
{ /Map Map .endmap def
} bind def
/begincodespacerange % <count> begincodespacerange -
{ pop mark
} bind def
/endcodespacerange % <code_lo> <code_hi> ... endcodespacerange -
{ counttomark 2 idiv { Map .addcodespacerange } repeat pop
} bind def
/.addcodespacerange % <code_lo> <code_hi> <map> .addcodespacerange -
{ 2 index length 1 eq
{ 2 { 3 -1 roll 0 get } repeat 1 exch
{ 2 copy 0 put pop } for pop
}
{ 2 index 0 get 1 3 index 0 get
6 -2 roll
2 { 1 1 index length 1 sub getinterval 6 1 roll } repeat
% Stack: lo hi map lo0 1 hi0
{ 2 copy get null eq { 2 copy 256 array put } if
4 copy get .addcodespacerange pop
}
for pop pop pop
}
ifelse
} bind def
/.endmap % <map> .endmap <map>
{ dup type /arraytype eq { dup { .endmap exch } forall astore readonly } if
} bind def
/usecmap % <CMap_name> usecmap -
{ /CMap findresource
dup length dict copy
currentdict end exch copy begin
} bind def
% ------ Rearranged font operators ------ %
/beginrearrangedfont % <font_name> <font*> beginrearrangedfont -
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
/endrearrangedfont % - endrearrangedfont -
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
/usefont % <fontID> usefont -
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
/beginusematrix % <fontID> beginusematrix -
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
/endusematrix % <matrix> endusematrix -
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
% ------ Character name/code selector operators ------ %
/beginbfchar % <count> beginbfchar -
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
/endbfchar % <code> <to_code|charname> ... endbfchar
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
/beginbfrange % <count> beginbfrange -
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
/endbfrange % <code_lo> <code_hi> <to_code|(charname*)> ...
% endbfrange -
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
% ------ CID selector operators ------ %
/begincidchar % <count> begincidchar -
{ pop mark
} bind def
/endcidchar % <code> <cid> ... endcidchar -
{ Map counttomark 2 idiv { 2 index 3 1 roll .addcidrange exch pop } repeat
/Map exch store pop
} bind def
/begincidrange % <count> begincidrange -
{ pop mark
} bind def
/endcidrange % <code_lo> <code_hi> <cid_base> ... endcidrange -
{ Map counttomark 3 idiv { .addcidrange exch pop } repeat
/Map exch store pop
} bind def
/.addcidrange % <code_lo> <code_hi> <cid_base> <map> .addcidrange
% <cid_next> <map>
{ % We may be updating a (partly) read-only map from another CMap.
% If so, implement copy-on-write.
dup wcheck not { dup length array copy } if
3 index length 1 eq
{ 2 { 4 -1 roll 0 get } repeat 1 exch
{ 2 copy 4 index put pop exch 1 add exch } for
}
{ 3 index 0 get 1 4 index 0 get
7 -2 roll
2 { 1 1 index length 1 sub getinterval 7 1 roll } repeat
% Stack: lo hi next map lo0 1 hi0
{ 5 copy get .addcidrange
% Stack: lo hi oldnext map i next submap
exch 5 1 roll 4 -1 roll pop
% Stack: lo hi next map i submap
3 copy put pop pop
}
for 4 -2 roll pop pop
}
ifelse
} bind def
% ------ notdef operators ------ %
/beginnotdefchar % <count> beginnotdefchar -
{ pop mark
} bind def
/endnotdefchar % <code> <cid> ... endnotdefchar -
{ counttomark 2 idiv { 1 index exch .addnotdefrange } repeat pop
} bind def
/beginnotdefrange % <count> beginnotdefrange -
{ pop mark
} bind def
/endnotdefrange % <code_lo> <code_hi> <cid> ... endnotdefrange -
{ counttomark 3 idiv { .addnotdefrange } repeat pop
} bind def
/.addnotdefrange % <code_lo> <code_hi> <cid_base> .addnotdefrange -
{ (NOT IMPLEMENTED YET.\n) print flush
} bind def
% ---------------- Resource category definition ---------------- %
end readonly def
/defineresource where
{ pop
[/CIDFont /CMap]
{ /Generic /Category findresource dup length dict copy
/Category defineresource pop
}
forall
/CIDInit GS_CIDInit_ProcSet /ProcSet defineresource pop
}
if
.setglobal